package org.vison.wonfu.framework.codestyle.issue;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 收集并管理所有检查出的问题
 */
public class IssueCollector {
    private final List<Issue> issues = new ArrayList<>();
    
    /**
     * 添加一个问题
     */
    public void addIssue(Issue issue) {
        issues.add(issue);
    }
    
    /**
     * 获取所有问题
     */
    public List<Issue> getAllIssues() {
        return new ArrayList<>(issues);
    }
    
    /**
     * 按严重程度获取问题
     */
    public List<Issue> getIssuesBySeverity(Issue.Severity severity) {
        return issues.stream()
                .filter(issue -> severity.equals(issue.getSeverity()))
                .collect(Collectors.toList());
    }
    
    /**
     * 获取问题总数
     */
    public int getTotalIssueCount() {
        return issues.size();
    }
    
    /**
     * 按严重程度统计问题数量
     */
    public int getIssueCountBySeverity(Issue.Severity severity) {
        return (int) issues.stream()
                .filter(issue -> severity.equals(issue.getSeverity()))
                .count();
    }
}
